fid = fopen('1.simu_cn.names.txt','w');



sigma_percent_base=100;
len=500;

mus=1:5;
sigma_max=.99;
sigma_min=.01;
num_sigma=[50, 20, 10, 5, 5];
num_sigma=5*ones(5,1);
num_part=[10, 10, 10, 10, 10];
num_part=5*ones(5,1);
part_max=.99;
part_min=.01;

for jj=1:length(mus)
mu_num=mus(jj);

if mu_num ==1
	zero=0;
	mu=2;
	for i=1:num_sigma
		zero=zero+1;
		name=['1.', num2str(jj), '.', num2str(zero), '.simu_cn.txt'];
		sigma=mu*i/sigma_percent_base;
		part=1;
		muss=sprintf('mu%d', mu);
			muss=sprintf('M%d', mu);
			sigmas=sprintf('S%.2f', sigmaa);
			parts=sprintf('P%.2f', part);
			fprintf(fid, '%s %d %d %d%s%s%s\n', name, zero, zero, zero, muss, sigmas, parts);
		obj=gmdistribution(mu, sigma, part);
		y=random(obj, len);
		dlmwrite(name,y);
		
	end
	
elseif mu_num==2
	zero=0;
	mu=[2;3];
	[sigma_xx, sigma_yy]=meshgrid(sigma_min:(sigma_max-sigma_min)/num_sigma(jj):sigma_max);
	sigma_xy=[sigma_xx(:), sigma_yy(:)];
	sigmaa=zeros(1,1,mu_num);
	for i=1:length(sigma_xy)
		for j=1:mu_num
			sigmaa(j)=mu(j)*sigma_xy(i,j);
		end
		partxy=part_min:(part_max-part_min)/num_part(jj):part_max;
		partxy=partxy';
		part_xy=[partxy, flipud(partxy)];
		for k=1:length(part_xy)
			zero=zero+1;
			name=['1.', num2str(jj), '.', num2str(zero), '.simu_cn.txt'];
			part=part_xy(k,:);
			muss=sprintf('M%d', mu);
			sigmas=sprintf('S%.2f', sigmaa);
			parts=sprintf('P%.2f', part);
			fprintf(fid, '%s %d %d %d%s%s%s\n', name, zero, zero, zero, muss, sigmas, parts);
			obj=gmdistribution(mu, sigma, part);
			y=random(obj, len);
			dlmwrite(name,y);
			
		end
	end

elseif mu_num==3
	zero=0;
	mu=[1;2;3];
	[sigma_xx, sigma_yy, sigma_zz]=meshgrid(sigma_min:(sigma_max-sigma_min)/num_sigma(jj):sigma_max);
	sigma_xyz=[sigma_xx(:), sigma_yy(:), sigma_zz(:)];
	sigmaa=zeros(1,1,mu_num);
	for i=1:length(sigma_xyz)
		for j=1:mu_num
			sigmaa(j)=mu(j)*sigma_xyz(i,j);
		end
		[partxx, partyy, partzz]=meshgrid(part_min:(part_max-part_min)/num_part(jj):part_max);
		partxyz=[partxx(:), partyy(:), partzz(:)];
		for k=1:length(partxyz)
			zero=zero+1;
			name=['1.', num2str(jj), '.', num2str(zero), '.simu_cn.txt'];
			part=partxyz(k,:);
			muss=sprintf('M%d', mu);
			sigmas=sprintf('S%.2f', sigmaa);
			parts=sprintf('P%.2f', part);
			fprintf(fid, '%s %d %d %d%s%s%s\n', name, zero, zero, zero, muss, sigmas, parts);
			obj=gmdistribution(mu, sigmaa, part);
			y=random(obj, len);
			dlmwrite(name,y);
		end
	end
	
elseif mu_num==4
	zero=0;
	mu=[1;2;3;4];
	[sigma_xx, sigma_yy, sigma_zz, sigma_uu]=ndgrid(sigma_min:(sigma_max-sigma_min)/num_sigma(jj):sigma_max);
	sigma_xyz=[sigma_xx(:), sigma_yy(:), sigma_zz(:), sigma_uu(:)];
	sigmaa=zeros(1,1,mu_num);
	for i=1:length(sigma_xyz)
		for j=1:mu_num
			sigmaa(j)=mu(j)*sigma_xyz(i,j);
		end
		[partxx, partyy, partzz, partuu]=ndgrid(part_min:(part_max-part_min)/num_part(jj):part_max);
		partxyz=[partxx(:), partyy(:), partzz(:), partuu(:)];
		for k=1:length(partxyz)
			zero=zero+1;
			name=['1.', num2str(jj), '.', num2str(zero), '.simu_cn.txt'];
			part=partxyz(k,:);
			muss=sprintf('M%d', mu);
			sigmas=sprintf('S%.2f', sigmaa);
			parts=sprintf('P%.2f', part);
			fprintf(fid, '%s %d %d %d%s%s%s\n', name, zero, zero, zero, muss, sigmas, parts);
			obj=gmdistribution(mu, sigmaa, part);
			y=random(obj, len);
			dlmwrite(name,y);
		end
	end
elseif mu_num==5
	zero=0;
	mu=[0;1;2;3;4];
	[sigma_xx, sigma_yy, sigma_zz, sigma_uu, sigma_vv]=meshgrid(sigma_min:(sigma_max-sigma_min)/num_sigma(jj):sigma_max);
	sigma_xyz=[sigma_xx(:), sigma_yy(:), sigma_zz(:), sigma_uu(:), sigma_vv(:)];
	sigmaa=zeros(1,1,mu_num);
	for i=1:length(sigma_xyz)
		for j=1:mu_num
			sigmaa(j)=mu(j)*sigma_xyz(i,j);
		end
		[partxx, partyy, partzz, partuu, aprtvv]=meshgrid(part_min:(part_max-part_min)/num_part(jj):part_max);
		partxyz=[partxx(:), partyy(:), partzz(:), partuu(:)];
		for k=1:length(partxyz)
			zero=zero+1;
			name=['1.', num2str(jj), '.', num2str(zero), '.simu_cn.txt'];
			part=partxyz(k,:);
			muss=sprintf('M%d', mu);
			sigmas=sprintf('S%.2f', sigmaa);
			parts=sprintf('P%.2f', part);
			fprintf(fid, '%s %d %d %d%s%s%s\n', name, zero, zero, zero, muss, sigmas, parts);
			obj=gmdistribution(mu, sigmaa, part);
			y=random(obj, len);
			dlmwrite(name,y);
		end
	end
end

end



fclose(fid);